{$CLEO .qa}
{$USE CLEO+}
{$USE newOpcodes}
{$USE ini}

0000: NOP

script_name "BCHFDSL"

// By ArtemQa146

const
    Chef_1 = 31@
    obj_1 = 30@
    Ped_ID = 29@
    coords_x = 28@
    coords_y = 27@
    coords_z = 26@
    angle_1 = 25@
    progress = 24@
    render_S = 23@
    render_obj = 0@
end



                0087: coords_x = 0@ // (float)
                0087: coords_y = 1@ // (float)
                0087: coords_z = 2@ // (float)
                0087: angle_1 = 3@ // (float)
                0085: render_obj = 4@ // (int)


                repeat
                wait 0
                04ED: load_animation  "PedEventsMod"
                until 04EE:   animation "PedEventsMod" loaded

                Ped_ID = 168

                model.Load(Ped_ID)
                model.Load(2702)
                if
                    not model.Available(Ped_ID)
                then
                    repeat
                    wait 0
                    model.Load(Ped_ID)
                    until model.Available(Ped_ID)
                end
                if
                    not model.Available(2702)
                then
                    repeat
                    wait 0
                    model.Load(2702)
                    until model.Available(2702)
                end
                038B: load_requested_models

                009A: Chef_1 = create_actor_pedtype 4 model Ped_ID at coords_x coords_y coords_z
                0173: set_actor Chef_1 Z_angle_to angle_1

                0575: set_actor Chef_1 pinned_position 1
                0812: AS_actor Chef_1 perform_animation "vend_p_1" IFP "PedEventsMod" framedelta 1000.0 loopA 1 lockX 0 lockY 0 lockF 0 time -1  // versionB
                0E24: fix_char Chef_1 ground 0 brightness 1 and_fade_in 0
                
                0E2E: create_render_object_to_char_bone Chef_1 model 2702 bone 34 offset 0.05 0.03 0 rotation 90.0 90.0 0 store_to render_S
                0E31: set_render_object_visible render_S 0

                model.Destroy(Ped_ID)
                model.Destroy(2702)
                
                progress = 0
                obj_1 = -1

                repeat
                wait 0
                if
                    056D:   actor Chef_1 defined
                then

                    080E: get_actor Chef_1 ped_event_to 1@
                    if or
                        1@ == 49
                        1@ == 9
                        1@ == 15
                        1@ == 31
                        1@ == 59
                    then
                        00A1: put_actor Chef_1 at 379.5794 -1922.4711 7.8301
                        0575: set_actor Chef_1 pinned_position 0
                        0E24: fix_char Chef_1 ground 1 brightness 1 and_fade_in 0
                        break
                    end

                    if or
                        0118:   actor Chef_1 dead
                        not locate_char_distance_to_char $player_actor char Chef_1 radius 120.0
                        not $ACTIVE_INTERIOR == 0
                        051A:   actor Chef_1 damaged_by_actor $PLAYER_ACTOR
                        not is_char_script_controlled Chef_1
                    then
                        00A1: put_actor Chef_1 at 379.5794 -1922.4711 7.8301
                        0575: set_actor Chef_1 pinned_position 0
                        0E24: fix_char Chef_1 ground 1 brightness 1 and_fade_in 0
                        break
                    end

                    if
                        0457:   player $PLAYER_CHAR aiming_at_actor Chef_1
                    then
                        0E83: get_current_char_weaponinfo $PLAYER_ACTOR store_to 1@
                        0E89: get_weaponinfo_fire_type 1@ store_to 2@ //     
                        if or
                            2@ == 1 //  
                            2@ == 3 //   (  ..)
                        then
                            00A1: put_actor Chef_1 at 379.5794 -1922.4711 7.8301
                            0575: set_actor Chef_1 pinned_position 0
                            0E24: fix_char Chef_1 ground 1 brightness 1 and_fade_in 0
                            break
                        end
                    end
                    
                    gosub @Eat

                end
                until not player.Defined(0)
                
                if
                    progress > 0
                then
                    if
                        obj_1 > 0
                    then
                        0E2F: delete_render_object obj_1
                    end
                end

                if 056D:   actor Chef_1 defined
                then 01C2: remove_references_to_actor Chef_1 // Like turning an actor into a random pedestrian
                end
                04EF: release_animation "PedEventsMod"

                repeat
                wait 0
                until not locate_char_distance_to_coordinates $PLAYER_ACTOR pos coords_x coords_y coords_z radius 120.0

0A93: terminate_this_custom_script



:Eat
    if and
        progress == 0
        0EEA: locate_char_distance_to_coordinates $PLAYER_actor pos 379.0851 -1924.2092 7.8301 radius 5.0
    then
        if and
            010A:   player $PLAYER_CHAR money > 2
            00F0:   actor $PLAYER_actor 1 near_point 379.5851 -1924.2092 radius 0.6 0.6 stopped_on_foot
        then
            progress = 1
        end
    end

    if
        progress == 1
    then
        0109: player $PLAYER_CHAR money += -2
        0172: 1@ = actor Chef_1 Z_angle
        1@ += 180.0
        0173: set_actor $PLAYER_ACTOR Z_angle_to 1@

        0615: define_AS_pack_begin 1@
        0812: AS_actor -1 perform_animation "ice_ped" IFP "PedEventsMod" framedelta 2.0 loopA 0 lockX 1 lockY 1 lockF 0 time -1
        0812: AS_actor -1 perform_animation "ice_2" IFP "PedEventsMod" framedelta 2.0 loopA 0 lockX 1 lockY 1 lockF 0 time -1
        0616: define_AS_pack_end 1@
        0618: assign_actor $PLAYER_actor to_AS_pack 1@
        061B: remove_references_to_AS_pack 1@

        0615: define_AS_pack_begin 1@
        0812: AS_actor -1 perform_animation "restq_sell" IFP "PedEventsMod" framedelta 2.0 loopA 0 lockX 0 lockY 0 lockF 0 time -1
        0812: AS_actor -1 perform_animation "vend_p_1" IFP "PedEventsMod" framedelta 2.0 loopA 1 lockX 0 lockY 0 lockF 0 time -1
        0616: define_AS_pack_end 1@
        0618: assign_actor Chef_1 to_AS_pack 1@
        061B: remove_references_to_AS_pack 1@
        progress = 2
    end
    
    if and
        8611:   not actor $PLAYER_actor performing_animation "ice_2"
        0611:   actor Chef_1 performing_animation "restq_sell"
    then
        0613: 1@ = actor Chef_1 animation "restq_sell" time
        if
            1@ > 0.55
        then
            0E31: set_render_object_visible render_S 1
        end
    end

    if and
        progress == 2
        0611:   actor $PLAYER_actor performing_animation "ice_2"
    then
        progress = 3
        timera = 0
        0226: 1@ = actor $PLAYER_actor health
        1@ += 10
        0223: set_actor $PLAYER_actor health_to 1@
        model.Load(2702)
        038B: load_requested_models
        0E2E: create_render_object_to_char_bone $PLAYER_actor model 2702 bone 34 offset 0.05 0.07 0 rotation -10.0 0 0 store_to obj_1
        0E37: set_render_object_scale obj_1 0.7 0.7 0.7
        0E31: set_render_object_visible render_S 0
        model.Destroy(2702)
    end

    if
        progress == 3
    then
        if or
            timera > 4000
            8611:   not actor $PLAYER_actor performing_animation "ice_2"
        then
            0E2F: delete_render_object obj_1
            obj_1 = -1
            progress = 4
        end
    end

    if
        progress == 4
    then
        if
            not locate_char_distance_to_coordinates $PLAYER_actor pos 379.0851 -1924.2092 7.8301 radius 3.0
        then
            progress = 0
        end
    end
return
